<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>国育工程建设 - 登录</title>

    <link rel="stylesheet" href="/assets/admin/css/bootstrap.min14ed.css?v=3.3.6" >
    <link rel="stylesheet" href="/assets/admin/css/font-awesome.min93e3.css?v=4.4.0" >
    <link rel="stylesheet" href="/assets/admin/css/animate.min.css" >
    <link rel="stylesheet" href="/assets/admin/css/style.min862f.css?v=4.1.0" >
    <link rel="stylesheet" href="/assets/admin/css/login.min.css" rel="stylesheet">
    <style type="text/css">
        body .layer-login .layui-layer-dialog .layui-layer-content {
            position: relative;
            padding: 20px;
            line-height: 24px;
            word-break: break-all;
            overflow: hidden;
            font-size: 14px;
            overflow-x: hidden;
            overflow-y: auto;
            color: #676a6c;
        }

        html #layui_layer_skinmoonstylecss {
            display: none;
            position: absolute;
            width: 1989px;
        }
        body .layer-ext-moon[type="dialog"] {
            min-width: 320px;
        }
        body .layer-ext-moon-msg[type="dialog"]{min-width:200px;}
        body .layer-ext-moon .layui-layer-title {
            background: #f6f6f6;
            color: #212a31;
            font-size: 16px;
            font-weight: bold;
            height: 46px;
            line-height: 46px;
        }



        body .layer-ext-moon .layui-layer-content .layui-layer-ico {
            height: 32px;
            width: 32px;
            top:18.5px;
            color: #676a6c;
        }
        body .layer-ext-moon .layui-layer-ico0 {
            background: url(default.png) no-repeat -96px 0;
        ;
        }
        body .layer-ext-moon .layui-layer-ico1 {
            background: url(default.png) no-repeat -224px 0;
        ;
        }
        body .layer-ext-moon .layui-layer-ico2 {
            background: url(default.png) no-repeat -192px 0;
        }
        body .layer-ext-moon .layui-layer-ico3 {
            background: url(default.png) no-repeat -160px 0;
        }
        body .layer-ext-moon .layui-layer-ico4 {
            background: url(default.png) no-repeat -320px 0;
        }
        body .layer-ext-moon .layui-layer-ico5 {
            background: url(default.png) no-repeat -288px 0;
        }
        body .layer-ext-moon .layui-layer-ico6 {
            background: url(default.png) -256px 0;
        }
        body .layer-ext-moon .layui-layer-ico7 {
            background: url(default.png) no-repeat -128px 0;
        }
        body .layer-ext-moon .layui-layer-setwin {
            top: 15px;
            right: 15px;
        }
        body .layer-ext-moon .layui-layer-setwin a {
            width: 16px;
            height: 16px;
        }
        body .layer-ext-moon .layui-layer-setwin .layui-layer-min cite:hover {
            background-color: #56abe4;
        }
        body .layer-ext-moon .layui-layer-setwin .layui-layer-max {
            background: url(default.png) no-repeat -80px 0;
        }
        body .layer-ext-moon .layui-layer-setwin .layui-layer-max:hover {
            background: url(default.png) no-repeat -64px 0;
        }
        body .layer-ext-moon .layui-layer-setwin .layui-layer-maxmin {
            background: url(default.png) no-repeat -32px 0;
        }
        body .layer-ext-moon .layui-layer-setwin .layui-layer-maxmin:hover {
            background: url(default.png) no-repeat -16px 0;
        }
        body .layer-ext-moon .layui-layer-setwin .layui-layer-close1,body .layer-ext-moon .layui-layer-setwin .layui-layer-close2 {
            background: url(default.png) 0 0;
        }
        body .layer-ext-moon .layui-layer-setwin .layui-layer-close1:hover,body .layer-ext-moon .layui-layer-setwin .layui-layer-close2:hover {
            background: url(default.png) -48px 0;
        }
        body .layer-ext-moon .layui-layer-padding{padding-top: 24px;}
        body .layer-ext-moon .layui-layer-btn {
            padding: 15px 0;
            background: #f0f4f7;
            border-top: 1px #c7c7c7 solid;
        }
        body .layer-ext-moon .layui-layer-btn a {
            font-size: 12px;
            font-weight: normal;
            margin: 0 3px;
            margin-right: 7px;
            margin-left: 7px;
            padding: 6px 20px;
            color: #fff;
            border: 1px solid #0064b6;
            background: #0071ce;
            border-radius: 3px;
            display: inline-block;
            height: 20px;
            line-height: 20px;
            text-align: center;
            vertical-align: middle;
            background-repeat: no-repeat;
            text-decoration: none;
            outline: none;
            -moz-box-sizing: content-box;
            -webkit-box-sizing: content-box;
            box-sizing: content-box;
        }
        body .layer-ext-moon .layui-layer-btn .layui-layer-btn0 {
            background: #0071ce;
        }
        body .layer-ext-moon .layui-layer-btn .layui-layer-btn1 {
            background: #fff;
            color: #404a58;
            border: 1px solid #c0c4cd;
            border-radius: 3px;
        }
        body .layer-ext-moon .layui-layer-btn .layui-layer-btn2 {
            background: #f60;
            color: #fff;
            border: 1px solid #f60;
            border-radius: 3px;
        }
        body .layer-ext-moon .layui-layer-btn .layui-layer-btn3 {
            background: #f00;
            color: #fff;
            border: 1px solid #f00;
            border-radius: 3px;
        }

        body .layer-ext-moon .layui-layer-title span.layui-layer-tabnow{
            height:46px;
        }
        .modal-body label{
            color: #666;
            margin-left: 4px;
        }
        .modal-body input{
            color:#000!important;
        }
        .modal-content h4{
            color: #666;
            text-align: center;
            font-size: 20px;
        }
        .modal-dialog{
            pointer-events：auto;
        }
    </style>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location
        }
        ;
    </script>

</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1>产教融合</h1>
                </div>
                <div class="m-b"></div>
                <h4>欢迎使用 <strong>产教融合后台管理系统</strong></h4>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势一:很好很强大</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势二:操作简单，界面简洁</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势三:......</li>
                </ul>
            </div>
        </div>
        <div class="col-sm-5">
            <form method="post">
                <h4 class="no-margins">登录：</h4>
                <p class="m-t-md" id="showMsgId">登录到产教融合后台管理系统</p>
                <input type="text" class="form-control uname" placeholder="用户名" name="userName" id="userName"/>
                <input type="password" class="form-control pword m-b" placeholder="密码" name="passwd" id="passwd"/>
                <button type="button" class="btn btn-success btn-block" id="loginBtn">登录</button>
            </form>
        </div>
    </div>
</div>
<!-- Button trigger modal -->
<#--<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">-->
<#--Launch demo modal-->
<#--</button>-->

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">距离上次修改密码已超过180天，您需要再次修改密码</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label for="usename">用户名</label>
                        <input type="text" class="form-control" id="usename" placeholder="请输入用户名">
                    </div>
                    <div class="form-group">
                        <label for="oldPass">旧密码</label>
                        <input type="password" class="form-control" id="oldPass" placeholder="请输入旧密码">
                    </div>
                    <div class="form-group">
                        <label for="newPass">新密码</label>
                        <input type="password" class="form-control" id="newPass" placeholder="请输入新密码">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                <button type="button" class="btn btn-primary" id="changePwd">确认</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/assets/admin/js/jquery.min.js?v=2.1.4"></script>
<script type="text/javascript" src="/assets/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script type="text/javascript">
    $(function () {
        $("#loginBtn").click(function () {
            var userName = $("#userName").val();
            var passwd = $("#passwd").val();
            var $showMsg = $("#showMsgId");
            $.ajax({
                type: 'POST',
                url: '/admin/login.json',
                data: {userName: userName, passwd: passwd},
                success: function (data) {
                    if(data.errmsg == "距离上次修改密码已超过180天，您需要再次修改密码"){
                        $('#usename').val($("#userName").val())

                        $('#myModal').modal('show')
                        $('#usename').attr('disabled','disabled');
                    }else{
                        if (data.ret) {
                            location.href = "/admin/index.htm";
                        } else {
                            if(data.errmsg == "抱歉，您没有登陆权限"){
                                alert(data.errmsg);
                                return
                            }
                            $showMsg.html("登录失败,失败原因:"+data.errmsg);
                            if(data.errmsg != "用户不存在"){
                                if(data.errmsg == "输入密码次数超过限制，请稍后再试"){
                                    $('#loginBtn').attr('disabled','disabled');
                                    $(document)[0].cookie = 'ckey='+30;
                                    console.log('cookie 设置完毕');
                                    t = setInterval(function(){
                                        setCookie();
                                    },1000)
                                }
                            }
                        }
                    }

                },
                error: function (data) {
                    console.log(data.errmsg);
                },
            });
        });
    });
    //修改密码
    $('#changePwd').on('click',function () {
        var usename = $('#usename').val();
        var oldPass = $('#oldPass').val();
        var newPass = $('#newPass').val();
        if(!isPassword(newPass)){
            // onf = true;
            alert('密码必须由8位以上的字母及数字共同组成');
            return false
        }
        //var formatpassword = RegExp(/^(?![^a-zA-Z]+$){8,}/).test(newPass);
        $.ajax({
            type:'POST',
            url:"/admin/coerceEditPwd.json",
            data:{
                userName:usename,
                passwd:oldPass,
                newPasswd:newPass
            },
            success:function (data) {
                if(data.ret){
                    alert('修改成功');
                    $('#myModal').modal('hide');
                }else{
                    alert(data.errmsg)
                }
                console.log(data);
            }

        })
    })
    //获取cookies
    function  getCookie() {
        var cookie = $(document)[0].cookie;
        var citem = cookie.split(',');
        var ckey = citem.filter(function (item) {
            return item.split('=')[0].trim()=='ckey';
        })
        // 获得 时间  cval
        cval = ckey[0].split('=')[1];
        return cval;
    }
    //查看cookie
    function setStyle() {
        var cval = getCookie();
        if(cval>1){
            $('#loginBtn').text(cval);
            $('#loginBtn').attr('disabled','disabled');
            t = setInterval(function(){
                setCookie();
            },1000)
        }else{
            $('#loginBtn').text('登录');
            $('#loginBtn').attr('disabled',false);
        }
    }
    setStyle();
    //设置cookie
    function setCookie() {
        var cval = getCookie();
        if(cval>1){
            $(document)[0].cookie = 'ckey='+(cval-1);
            $('#loginBtn').text(cval);
            $('#loginBtn').attr('disabled','disabled');
        }else{
            $('#loginBtn').text('登录');
            $('#loginBtn').attr('disabled',false);
            $(document)[0].cookie = 'ckey='+0;
        }
    }

    function isPassword(password){
        var formatpassword = RegExp(/^(?![^a-zA-Z]+$)(?!\D+$).{8,}/).test(password);
        if(formatpassword){
            return true;
        }else{
            return false;
        }
    }
</script>
</body>
</html>